1. Field of the Invention
The present invention relates generally to computer systems and, in particular, to physical implementations of look-up switch statements in a computer system.
2. Discussion of Related Art
Many individuals and organizations in the computer and communications industries tout the Internet as the fastest growing market on the planet. In the 1990s, the number of users of the Internet appears to be growing exponentially with no end in sight. In June of 1995, an estimated 6,642,000 hosts were connected to the Internet; this represented an increase from an estimated 4,852,000 hosts in January, 1995. The number of hosts appears to be growing at around 75% per year. Among the hosts, there were approximately 120,000 networks and over 27,000 web servers. The number of web servers appears to be approximately doubling every 53 days.
In July 1995, with over 1,000,000 active Internet users, over 12,505 usenet news groups, and over 10,000,000 usenet readers, the Internet appears to be destined to explode into a very large market for a wide variety of information and multimedia services.
In addition, to the public carrier network or Internet, many corporations and other businesses are shifting their internal information systems onto an intranet as a way of more effectively sharing information within a corporate or private network. The basic infrastructure for an intranet is an internal network connecting servers and desktops, which may or may not be connected to the Internet through a firewall. These intranets provide services to desktops via standard open network protocols which are well established in the industry. Intranets provide many benefits to the enterprises which employ them, such as simplified internal information management and improved internal communication using the browser paradigm. Integrating Internet technologies with a company's enterprise infrastructure and legacy systems also leverages existing technology investment for the party employing an intranet. As discussed above, intranets and the Internet are closely related, with intranets being used for internal and secure communications within the business and the Internet being used for external transactions between the business and the outside world. For the purposes of this document, the term "networks" includes both the Internet and intranets. However, the distinction between the Internet and an intranet should be born in mind where applicable.
In 1990, programmers at Sun Microsystems wrote a universal programming language. This language was eventually named the JAVA programming language. (JAVA is a trademark of Sun Microsystems of Mountain View, Calif.) The JAVA programming language resulted from programming efforts which initially were intended to be coded in the C++ programming language; therefore, the JAVA programming language has many commonalties with the C++ programming language. However, the JAVA programming language is a simple, object-oriented, distributed, interpreted yet high performance, robust yet safe, secure, dynamic, architecture neutral, portable, and multi-threaded language.
The JAVA programming language has emerged as the programming language of choice for the Internet as many large hardware and software companies have licensed it from Sun Microsystems. The JAVA programming language and environment is designed to solve a number of problems in modern programming practice. The JAVA programming language omits many rarely used, poorly understood, and confusing features of the C++ programming language. These omitted features primarily consist of operator overloading, multiple inheritance, and extensive automatic coercions. The JAVA programming language includes automatic garbage collection that simplifies the task of programming because it is no longer necessary to allocate and free memory as in the C programming language. The JAVA programming language restricts the use of pointers as defined in the C programming language, and instead has true arrays in which array bounds are explicitly checked, thereby eliminating vulnerability to many viruses and nasty bugs. The JAVA programming language includes objective-C interfaces and specific exception handlers.
The JAVA programming language has an extensive library of routines for coping easily with TCP/IP protocol (Transmission Control Protocol based on Internet protocol), HTTP (Hypertext Transfer Protocol) and FTP (File Transfer Protocol). The JAVA programming language is intended to be used in networked/distributed environments. The JAVA programming language enabled the construction of virus-free, tamper-free systems. The authentication techniques are based on public-key encryption.
Many computer systems, including those implementing the JAVA programming language, include look-up switch statements (which are used for jump tables) within their instruction sets. Table 1 provides a high level outline of a look-up switch statement, SWITCH (SHAPE).
TABLE 1 ______________________________________ SWITCH (SHAPE) RECTANGLE: BEGIN . . END CIRCLE: BEGIN . . END TRIANGLE: BEGIN . . END DEFAULT: BEGIN . . END ______________________________________
In the look-up switch statement of Table 1, the variable SHAPE is iteratively compared with the match values RECTANGLE, CIRCLE and TRIANGLE. If a match exists between the variable SHAPE and one of the match values, then code associated with the match value causing the match is accessed. If a match does not exist between the variable SHAPE and any of the match values, the code associated with a default value, DEFAULT is accessed. The code associated with the match values is represented by the BEGIN . . . END statements in Table 1. When analyzed at a lower level, a look-up switch statement has a corresponding program counter value which uniquely identifies the look-up switch statement. A look-up switch statement also has an associated variable, MATCH (e.g., SHAPE in Table 1). As described in more detail below, the value of the variable MATCH is used to determine the next instruction to be implemented.
Also associated with the look-up switch statement are one or more constant values, MATCH.sub.-- 1, MATCH.sub.-- 2 . . . MATCH.sub.-- N (e.g., RECTANGLE, CIRCLE, TRIANGLE in Table 1). Each of these constant values has a corresponding jump offset value, JUMP.sub.-- OFFSET.sub.-- 1, JUMP.sub.-- OFFSET.sub.-- 2 . . . JUMP.sub.-- OFFSET.sub.-- N. The variable MATCH is iteratively compared with each of the constant values MATCH.sub.-- 1, MATCH.sub.-- 2 . . . MATCH.sub.-- N. If an equality is detected between the variable MATCH and one of the constant values (e.g., MATCH.sub.-- 2), the corresponding jump offset value (e.g., JUMP.sub.-- OFFSET.sub.-- 2) is added to the program counter value, thereby causing processing to continue with the instruction identified by the new program counter value. If an equality is not detected, then a default jump offset value is added to the program counter value.
The step-by-step comparisons required by conventional look-up switch statements can require hundreds of cycles, and therefore consume valuable time until the appropriate jump offset value is retrieved and instruction execution resumes. It would therefore be desirable to have a method and apparatus for accelerating the execution of a look-up switch statement.